<template>
    <div class="secretaryHeader">
        <el-menu class="el-menu-demo" mode="horizontal" @select="handleSelect" background-color="#ffffff" v-model="username"
            text-color="#1a1d27">
            <span class="userName">欢迎 {{ username }}</span>
            <span class="logout" @click="Logout">退出登录</span>
        </el-menu>
    </div>
</template>

<script>
export default {
    name: "SecretaryHeader",
    data() {
        return {
            username: "",
        }

    },
    methods: {
        handleSelect(key, keyPath) {
            // console.log(key, keyPath);
        },
        //获取姓名
        getName() {
            let userInfo = localStorage.getItem("secretaryInfo") ? JSON.parse(localStorage.getItem("secretaryInfo")) : null
            if (userInfo == null) {
                this.$message({
                    type: 'error',
                    message: '用户信息丢失，请重新登录',
                })
            } else {
                this.username = userInfo.nickname
            }
        },
        //退出登录
        Logout() {
            localStorage.removeItem('secretaryInfo');
            this.$router.push('/');
        }
    },
    mounted() {
        this.getName();


    }
};
</script>


<style scoped>
.el-menu-demo {
    text-align: right;
    line-height: 50px;
    font-size: 20px;
    font-weight: 700;
    font-family: canger;
}

.userName,
.logout {
    margin-right: 40px;
}

.logout:hover {
    color: red;
    cursor: pointer
}
</style>